<?php

namespace addons\csmitsm\library\xcore\xcflow\utils\xcformfields\xcform;

use addons\csmitsm\library\sdnode\xstack\utils\XsJsonUtils;
use addons\csmitsm\library\xcore\xcflow\utils\xcformfields\xcform\base\XcflowAField;

class xcform_control_objselectmulti extends XcflowAField
{
    public function getDbfieldColumnType()
    {
        return "varchar(255)";
    }
    public function assertXcfieldjson()
    {
        $json = $this->fieldjsonobj;
        if (empty($json['xcform_base_inputfieldcode']['value'])) {
            $this->assertRequired("字段编码");
        }
        if (empty($json['xcform_base_xctitle']['value'])) {
            $this->assertRequired("字段名称");
        }
        if (empty($json['xcform_base_selecttablefield']['tablename'])) {
            $this->assertRequired("数据对象");
        }
        if (empty($json['xcform_base_selecttablefield']['showfields'])) {
            $this->assertRequired("显示字段");
        }
        if (empty($json['xcform_base_selecttablefield']['filterfields'])) {
            $this->assertRequired("过滤字段");
        }
    }

    public function pagevalueToDbvalue($pagevalue)
    {
        return XsJsonUtils::jsonToString($pagevalue);
    }

    public function dbvalueToPagevalue($dbvalue)
    {
        return XsJsonUtils::stringToJson($dbvalue);
    }
}
